import threading
import time , os , sys

sys.path.append("lib/log") 
sys.path.append("lib/db") 
sys.path.append("lib/io/in")
sys.path.append("lib/io/out")
sys.path.append("lib/comum") 
sys.path.append("entrada") 
sys.path.append("processamento") 
sys.path.append("saida") 


from log import Log
from entrada import Entrada
from processamento import Processamento
from saida import Saida

global sono
#sono=60
sono=10
		
class ThreadEntrada ( threading.Thread ):

	def run ( self ):
		log = Log()
		log.update('**Processador 2013 - Generic Data Processing Started!**\n')
		log.update('Thread['+ self.getName()+ '] started.\n')

		entrada = Entrada()

		while True:
			log.update('['+ self.getName()+ '][entrada] running...\n')
			entrada.verifica()
			time.sleep(sono)

		log.update('Thread['+ self.getName()+ '] ended.\n')

class ThreadProcessamento ( threading.Thread ):

	def run ( self ):
		log = Log()
		proc = Processamento()
		log.update('Thread'+ self.getName()+ 'started.\n')
		while True:
			log.update('['+ self.getName()+ '][processamento] running...\n')
			proc.run()
			time.sleep(sono)

		log.update('Thread'+ self.getName()+ 'ended.\n')

class ThreadSaida ( threading.Thread ):

	def run ( self ):
		log = Log()
		saida = Saida()
		log.update('Thread'+ self.getName()+ 'started.\n')
		while True:
			log.update('['+ self.getName()+ '][saida] running...\n')
			saida.entrega()
			time.sleep(sono)

		log.update('Thread'+ self.getName()+ 'ended.\n')

# local test
"""
thingOne = ThreadOne()
thingTwo = ThreadTwo()
thingTree = ThreadTree()
thingFour = ThreadFour()
thingOne.start()
thingTwo.start()
thingTree.start()
thingFour.start()
"""
